<template>
  <!-- 电子招标 -->
  <div class="tendering">
    <div class="header">
      <p class="title">电子招标版块</p>
    </div>
    <div class="display">
      <div class="item">
        <p class="val">
          <span class="icon icon1"></span>
          <count-to
            class="num"
            :startVal="0"
            :endVal="amount.value || 0"
            :duration="1000"
          ></count-to>
        </p>
        <p class="key">{{ amount.name }}({{ amount.unit }})</p>
      </div>
      <span class="line"></span>
      <div class="item">
        <p class="val">
          <span class="icon icon2"></span>
          <count-to
            class="num"
            :startVal="0"
            :endVal="bids.value || 0"
            :duration="1000"
          ></count-to>
        </p>
        <p class="key">{{ bids.name }}({{ bids.unit }})</p>
      </div>
      <span class="line"></span>
      <div class="item">
        <p class="val">
          <span class="icon icon3"></span>
          <count-to
            class="num"
            :startVal="0"
            :endVal="publications.value || 0"
            :duration="1000"
          ></count-to>
        </p>
        <p class="key">{{ publications.name }}({{ publications.unit }})</p>
      </div>
    </div>
    <div class="chart-wrap">
      <Echart id="tender-chart" :options="option" height="255px" width="100%" />
    </div>
  </div>
</template>

<script setup>
import { reactive, ref, onMounted } from "vue";
import Echart from "@/components/echart/index.vue";
import CountTo from "@/components/vueCountTo/vue-countTo.vue";
import { ajax } from "@/store/service";
import { dataGroup } from "@/utils";
import opt from "./eTenderingOpt";

const amount = ref({});
const bids = ref({});
const publications = ref({});
const option = reactive({ ...opt });

const init = async () => {
  const [res] = await ajax.tender();
  amount.value=res.amount
  bids.value=res.bids
  publications.value=res.publications
  const chart = dataGroup(res.chart);
  option.xAxis[0].data = chart.x;
  option.series[0].data = chart.y;

};
onMounted(() => {
  init();
});
</script>
<style scoped lang='scss'>
.tendering {
  width: 548px;
  height: 426px;
  .header {
    width: 100%;
    height: 80px;
    background: url("@/assets/longscreen2/title-short.png");
    box-sizing: border-box;
    padding-top: 15px;
    .title {
      font-size: 22px;
      font-family: JLinXin;
      font-weight: 600;
      line-height: 22px;
      background: #fffde8 linear-gradient(180deg, #e8feff 40%, #00a9ff 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      font-weight: bold;
      margin-left: 68px;
    }
  }
  .display {
    height: 65px;
    // border: #00a9ff 1px solid;
    display: flex;
    padding-left: 26px;
    justify-content: space-between;
    margin-bottom: 26px;
    .item {
      //   border: #4dff00 1px solid;
      .val {
        display: flex;
        align-items: flex-end;
        margin-bottom: 12px;
        .icon {
          width: 30px;
          height: 30px;
          display: block;
        }
        .icon1 {
          background: url("@/assets/longscreen2/icon_招标金额.svg");
        }
        .icon2 {
          background: url("@/assets/longscreen2/icon_招标数.svg");
        }
        .icon3 {
          background: url("@/assets/longscreen2/icon_月均发布数.svg");
        }
        .num {
          font-size: 28px;
          font-family: D-DIN-PRO-Heavy, D-DIN-PRO;
          font-weight: 800;
          color: #ffffff;
          line-height: 28px;
          margin-left: 8px;
        }
        .unit {
          font-size: 18px;
          font-family: SourceHanSansCN-Medium, SourceHanSansCN;
          font-weight: 500;
          color: #ffffff;
          opacity: 0.36;
          margin-left: 4px;
        }
      }
      .key {
        font-size: 18px;
        font-family: SourceHanSansCN-Medium, SourceHanSansCN;
        font-weight: 500;
        color: #ffffff;
        line-height: 27px;
        opacity: 0.7;
      }
    }
    .line {
      width: 1px;
      height: 52px;
      background: linear-gradient(
        180deg,
        rgba(9, 217, 242, 0) 0%,
        #09d7f0 51%,
        rgba(9, 214, 239, 0) 100%
      );
    }
  }
  .chart-wrap {
    width: 514px;
    height: 255px;
    // border: #00a9ff 1px solid;
    margin-left: 31px;
  }
}
</style>